<?php
/*require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php';*/
/**
 *向pdm同步产品清仓标示数据
 *@author shipanpan
 */
/*class SynProductClearanceController extends Controller_CronJob {
public function run() {
$pdmDomain = Helper_Config::get('url', 'pdm', 'url');
$url = $pdmDomain . 'interface/clearance/index';

try {
$now = date("Y-m-d H:i:s");
$result = Controller_Interface::post($url, ['update_time_start' => $now]);
} catch (Exception $e) {
$errorMsg = "请求清仓数据发生错误:" . $e->getMessage();
$this->log->record($errorMsg, Log::ALERT);
die($errorMsg);
}

if (!$result) {
die('未有待更新的清仓数据！');
}

$result = json_decode($result, true);
if (!$result) {
$errorMsg = "清仓数据格式异常,错误原因:" . json_last_error_msg();
$this->log->record($errorMsg, Log::ALERT);
}

if (is_array($result) && $result) {
foreach ($result as $_oneRow) {
$goodsSn = $this->writeDb->quote($_oneRow['goods_sn']);
$warehouse = $this->writeDb->quote($_oneRow['wh_code']);
$clearanceFlag = $this->writeDb->quote($_oneRow['is_clearance']);
$is_clearance_update_time = $this->writeDb->quote($_oneRow['create_time']);

$this->writeDb->query("INSERT INTO p_warehouse_product (goods_sn,warehouse,is_clearance,is_clearance_update_time) VALUES($goodsSn,$warehouse,$clearanceFlag,$is_clearance_update_time) ON DUPLICATE KEY UPDATE is_clearance=$clearanceFlag , is_clearance_update_time=$is_clearance_update_time");
}
}
die('成功更新清仓标示！');
}

}
$SynProductClearanceController = new SynProductClearanceController();
$SynProductClearanceController->run();*/

//已改为主动推送，见interface模块